02. Matrix Addition
Matrix Addition
To add one matrix to the other we need to:
- Verify that the matrices are of the same dimensions
- Make sure we add elements in the correct corresponding index.
To put this into context, let's look at an example:
We will focus on the random matrix we saw in equation 11:
A=\begin{bmatrix} a_{11} &a_{12} &a_{13}&..& a_{1n}\\ a_{21} &a_{22} &a_{23}&..& a_{2n}\\a_{31} &a_{32} &a_{33}&..& a_{3n}\\ :\\a_{m1} &a_{m2} &a_{m3}&……& a_{mn}\end{bmatrix}
The dimensions of matrix A are mxn.
This means that the matrix has m rows and n columns.
Matrix A can only be added to another matrix with m rows and n columns. For example, matrix B.
B=\begin{bmatrix} b_{11} &b_{12} &b_{13}&..& b_{1n}\\ b_{21} &b_{22} &b_{23}&..& b_{2n}\\b_{31} &b_{32} &b_{33}&..& b_{3n}\\ :\\b_{m1} &b_{m2} &b_{m3}&……& b_{mn}\end{bmatrix}
Equation 12
As long as the dimensions match, the addition is very simple:
Simply add element a_{ij} in A to the corresponding element b_{ij} in B.
A+B=\begin{bmatrix} a_{11} &a_{12} &a_{13}&..& a_{1n}\\ a_{21} &a_{22} &a_{23}&..& a_{2n}\\a_{31} &a_{32} &a_{33}&..& a_{3n}\\ :\\a_{m1} &a_{m2} &a_{m3}&……& a_{mn}\end{bmatrix}+\begin{bmatrix} b_{11} &b_{12} &b_{13}&..& b_{1n}\\ b_{21} &b_{22} &b_{23}&..& b_{2n}\\b_{31} &b_{32} &b_{33}&..& b_{3n}\\ :\\b_{m1} &b_{m2} &b_{m3}&……& b_{mn}\end{bmatrix}
A+B=\begin{bmatrix} a_{11}+ b_{11} &a_{12}+ b_{12} &a_{13}+ b_{13}&..& a_{1n}+ b_{1n}\\ a_{21}+ b_{21} &a_{22} + b_{22}&a_{23}+ b_{23}&..& a_{2n}+ b_{2n}\\a_{31}+ b_{31} &a_{32}+ b_{32} &a_{33}+ b_{33}&..& a_{3n}+ b_{3n}\\ :\\a_{m1}+ b_{m1} &a_{m2}+ b_{m2} &a_{m3}+ b_{m3}&……& a_{mn}+ b_{mn}\end{bmatrix}
Equation 12